import { INCREAMENTCOUNT, DECREAMENTCOUNT } from "../constant/countConsts"
const init = {
  count: 0
}
export default function countReducer(prevState = init, action) {
  // console.log("reducer调用了");
  //接受action对象的type和data

  const { type,
    data } = action

  switch (type) {
    case INCREAMENTCOUNT:
      return {
        ...init, count: prevState.count + data
      };

    case DECREAMENTCOUNT:
      return {
        ...init, count: prevState.count - data
      }
  }

  return prevState;

}